<!-- 管理员用户组新增和编辑页面 -->
{extend name="common/main" /}
{block name="body"}
    <div class="main-title">
        <h2>{:lang("_USER_HAS_EXTENDED_DATA_FIELD_CONFIGURATION_")}</h2>
    </div>
    <div class="with-padding">
        <div class="tab-wrap row clearfix">
            <div class="col-xs-10">
                {include file="role/_link"/}
            </div>
            <div class="col-xs-2 text-right">
                <select name="role" class="form-control">
                    {volist name="role_list" id="vo"}
                        <option value="{:url('Role/configfield',array('id'=>$vo['id']))}"
                        {eq name="vo['id']" value="$this_role['id']"}selected{/eq}
                        >{$vo.title}</option>
                    {/volist}
                </select>
            </div>
        </div>

        <div>
            <!-- 访问授权 -->
            <div class="node-list in">
                <form action="{:url()}" enctype="application/x-www-form-urlencoded" method="POST" class="form-horizontal auth-form">
                    {notempty name="field_list"}
                        {volist name="field_list" id="group"}
                            <dl class="checkmod">
                                <dt class="hd">
                                    <label class="checkbox"><input class="auth_fields fields_all" type="checkbox">{$group.profile_name}</label>
                                </dt>
                                <dd class="bd">
                                    {present name="group['field_list']"}
                                        {volist name="group['field_list']" id="field"}
                                            <div class="filed_check">
                                                <div>
                                                    <label class="checkbox"
                                                           title="id：{$field['id']} {:lang("_FIELD_TYPE_")}{:lang("_COLON_")}{$field['form_type']}">
                                                        <input class="auth_fields fields_row" type="checkbox"
                                                               name="fields[]" value="{$field.id}"/>{$field.field_name}
                                                    </label>
                                                </div>
                                            </div>
                                        {/volist}
                                    {/present}
                                    <div class="clearfix"></div>
                                </dd>
                            </dl>
                        {/volist}
                    {else/}
                        <div style="margin: 10px;color: rgb(255, 81, 81);">
                            {:lang("_FIRST_TO_USER_MANAGEMENT_USER_MANAGEMENT_WITH_SPACE_")}中
                            <a href="{:url('admin/user/profile')}" title="" target="_blank" style="color: rgb(255, 81, 81);text-decoration: underline;">
                                {:lang("_ADD_USER_EXTENSION_")}
                            </a>~
                        </div>
                    {/notempty}

                    <input type="hidden" name="id" value="{$this_role.id}"/>
                    <button type="submit" class="btn submit-btn ajax-post" target-form="auth-form">{:lang("_SURE_WITH_SPACE_")}</button>
                    <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">{:lang("_RETURN_WITH_SPACE_")}</button>
                    <span style="color: #BABABA;margin: 11px;">{:lang("_PLEASE_SAVE_THE_ABOVE_CONFIGURATION_AND_THEN_SWITCH_TO_ANOTHER_INTERFACE_")}</span>
                </form>
            </div>
        </div>
    </div>
    <style>
        .filed_check {
            width: 200px;
            float: left;
            margin: 5px 0;
        }
    </style>
{/block}
{block name="script"}
    <script type="text/javascript" charset="utf-8">
        +function ($) {
            var fields = [{$this_role.fields}];
        $('.auth_fields').each(function () {
            if ($.inArray(parseInt(this.value, 10), fields) > -1) {
                $(this).prop('checked', true);
            }
            if (this.value == '') {
                $(this).closest('span').remove();
            }
        });

        //全选节点
        $('.fields_all').on('change', function () {
            $(this).closest('dl').find('dd').find('input').prop('checked', this.checked);
        });
        $('.fields_row').on('change', function () {
            $(this).closest('.filed_check').find('.child_row').find('input').prop('checked', this.checked);
        });

        $('select[name="role"]').change(function () {
            location.href = this.value;
        });
 
    }(jQuery);
    </script>
{/block}
